/**
 * @Description:  基础公共数据
 * @Author:       zhengxu
 * @Date: 2021-10-12 16:37:14
 * @LastEditors:  zhengxu
 * @LastEditTime: 2021-11-13 14:39:12
 */
/* eslint-disable no-param-reassign */
export default {
  namespaced: true,
  state: {
    activeMenu: '',
    menuList: []
  },
  mutations: {
    setActive (state, path) {
      state.activeMenu = path
    },
    setMenu ({ menuList }, menu) {
      if (!menuList.some(({ name }) => name === menu.name)) menuList.push(menu)
    },
    removeMenu ({ menuList }, index) {
      if (index >= 0 && index < menuList.length) menuList.splice(index, 1)
    }
  }
}
